package 移动距离;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int w = in.nextInt();
        int m = in.nextInt()-1;
        int n = in.nextInt()-1;
        int x1 = m / w;
        int y1 = m % w;
        int x2 = n / w;
        int y2 = n % w;
        if (x1 % 2 != 0) {
            y1 = w - 1 - y1;
        }
        if (x2 % 2 != 0) {
            y2 = w - 1 - y2;
        }
        System.out.println(Math.abs(x1 - x2) + Math.abs(y1 - y2));
    }
}
